#include "simple.h"

std::string::size_type SimpleMatch(std::string_view target,
                                   std::string_view pattern) {
  auto n = target.length();
  auto m = pattern.length();
  auto i = 0;

  for (auto s = 0; s <= n - m; ++s) {
    for (i = 0; i < m; ++i) {
      if (pattern[i] != target[s + i]) {
        break;
      }
    }
    if (i == m) {
      return s;
    }
  }

  return std::string::npos;
}
